package com.jy.adscm.stock.controller;


import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.security.utils.Token;
import com.jy.adscm.stock.bean.JyInStorage;
import com.jy.adscm.stock.bean.JyRemainingStorage;
import com.jy.adscm.stock.service.JyRemainingStorageService;
import com.jy.adscm.support.SimpleCoreResponse;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zyl
 * @since 2019-01-23
 */
@RestController
@RequestMapping("/adscm/stock/jyRemainingStorage")
public class JyRemainingStorageController {
    @Autowired
   JyRemainingStorageService JyRemainingStorageService;
    @Autowired
    RedisTemplate<Object, Token> tokenRedisTemplate;
    @RequestMapping("selectAll")
    public SimpleCoreResponse selectAll(HttpServletRequest request) throws AdscmSystemException {
        String tokenId = request.getParameter("tokenId");
        Token token = AdscmBaseUtils.getInstance().getTokenByTokenId(tokenId, tokenRedisTemplate);
        List<JyRemainingStorage> jyRemainingStorages=JyRemainingStorageService.selectAll(token);
        return new SimpleCoreResponse("200","查询成功",jyRemainingStorages);
    }
}

